Add some more attribute tests.
authorMatthias Clasen <mclasen@redhat.com>
Fri, 29 Apr 2005 14:43:50 +0000 (14:43 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 29 Apr 2005 14:43:50 +0000 (14:43 +0000)
2005-04-29  Matthias Clasen  <mclasen@redhat.com>

* tests/testtext.c: Add some more attribute tests.

* gtk/gtktexttag.c (gtk_text_tag_class_init): Correct the documentation
of the rise property. String change, but it is more important to
be correct than to be translated.  (#301740)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtktexttag.c
tests/testtext.c

index f879e57fc7445074bad39a92f5ec7c18fb1af83d..a867a8f75d6e2127f8dbdff9917a5c433713a566 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-04-29  Matthias Clasen  <mclasen@redhat.com>
+
+       * tests/testtext.c: Add some more attribute tests.
+
+       * gtk/gtktexttag.c (gtk_text_tag_class_init): Correct the documentation
+       of the rise property. String change, but it is more important to
+       be correct than to be translated.  (#301740)
+
 2005-04-25  Tor Lillqvist  <tml@novell.com>
 
        * gtk/gtkfilesystemwin32.c
index f879e57fc7445074bad39a92f5ec7c18fb1af83d..a867a8f75d6e2127f8dbdff9917a5c433713a566 100644 (file)
@@ -1,3 +1,11 @@
+2005-04-29  Matthias Clasen  <mclasen@redhat.com>
+
+       * tests/testtext.c: Add some more attribute tests.
+
+       * gtk/gtktexttag.c (gtk_text_tag_class_init): Correct the documentation
+       of the rise property. String change, but it is more important to
+       be correct than to be translated.  (#301740)
+
 2005-04-25  Tor Lillqvist  <tml@novell.com>
 
        * gtk/gtkfilesystemwin32.c
index f879e57fc7445074bad39a92f5ec7c18fb1af83d..a867a8f75d6e2127f8dbdff9917a5c433713a566 100644 (file)
@@ -1,3 +1,11 @@
+2005-04-29  Matthias Clasen  <mclasen@redhat.com>
+
+       * tests/testtext.c: Add some more attribute tests.
+
+       * gtk/gtktexttag.c (gtk_text_tag_class_init): Correct the documentation
+       of the rise property. String change, but it is more important to
+       be correct than to be translated.  (#301740)
+
 2005-04-25  Tor Lillqvist  <tml@novell.com>
 
        * gtk/gtkfilesystemwin32.c
index 996b2d5d0f54cc06fcb6447b895a00dab198e2cc..56db57e46f34fec663463036404a207979909173 100644 (file)
@@ -424,7 +424,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    PROP_RISE,
                                    g_param_spec_int ("rise",
                                                      P_("Rise"),
-                                                     P_("Offset of text above the baseline (below the baseline if rise is negative) in pixels"),
+                                                     P_("Offset of text above the baseline (below the baseline if rise is negative) in Pango units"),
                                                     G_MININT,
                                                      G_MAXINT,
                                                      0,
index a33c90703d4d132ae14c07d6292bfa1626bebbd3..85d312c5ba4565eb4b8caebb233a42e351f31c8b 100644 (file)
@@ -28,6 +28,10 @@ struct _Buffer
   GtkTextTag *invisible_tag;
   GtkTextTag *not_editable_tag;
   GtkTextTag *found_text_tag;
+  GtkTextTag *rise_tag;
+  GtkTextTag *large_tag;
+  GtkTextTag *indent_tag;
+  GtkTextTag *margin_tag;
   GtkTextTag *custom_tabs_tag;
   GSList *color_tags;
   guint color_cycle_timeout;
@@ -1033,6 +1037,114 @@ do_apply_invisible (gpointer callback_data,
     }
 }
 
+static void
+do_apply_rise (gpointer callback_data,
+              guint callback_action,
+              GtkWidget *widget)
+{
+  View *view = view_from_widget (widget);
+  GtkTextIter start;
+  GtkTextIter end;
+  
+  if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer,
+                                            &start, &end))
+    {
+      if (callback_action)
+        {
+          gtk_text_buffer_remove_tag (view->buffer->buffer,
+                                      view->buffer->rise_tag,
+                                      &start, &end);
+        }
+      else
+        {
+          gtk_text_buffer_apply_tag (view->buffer->buffer,
+                                     view->buffer->rise_tag,
+                                     &start, &end);
+        }
+    }
+}
+
+static void
+do_apply_large (gpointer callback_data,
+               guint callback_action,
+               GtkWidget *widget)
+{
+  View *view = view_from_widget (widget);
+  GtkTextIter start;
+  GtkTextIter end;
+  
+  if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer,
+                                            &start, &end))
+    {
+      if (callback_action)
+        {
+          gtk_text_buffer_remove_tag (view->buffer->buffer,
+                                      view->buffer->large_tag,
+                                      &start, &end);
+        }
+      else
+        {
+          gtk_text_buffer_apply_tag (view->buffer->buffer,
+                                     view->buffer->large_tag,
+                                     &start, &end);
+        }
+    }
+}
+
+static void
+do_apply_indent (gpointer callback_data,
+                guint callback_action,
+                GtkWidget *widget)
+{
+  View *view = view_from_widget (widget);
+  GtkTextIter start;
+  GtkTextIter end;
+  
+  if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer,
+                                            &start, &end))
+    {
+      if (callback_action)
+        {
+          gtk_text_buffer_remove_tag (view->buffer->buffer,
+                                      view->buffer->indent_tag,
+                                      &start, &end);
+        }
+      else
+        {
+          gtk_text_buffer_apply_tag (view->buffer->buffer,
+                                     view->buffer->indent_tag,
+                                     &start, &end);
+        }
+    }
+}
+
+static void
+do_apply_margin (gpointer callback_data,
+                guint callback_action,
+                GtkWidget *widget)
+{
+  View *view = view_from_widget (widget);
+  GtkTextIter start;
+  GtkTextIter end;
+  
+  if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer,
+                                            &start, &end))
+    {
+      if (callback_action)
+        {
+          gtk_text_buffer_remove_tag (view->buffer->buffer,
+                                      view->buffer->margin_tag,
+                                      &start, &end);
+        }
+      else
+        {
+          gtk_text_buffer_apply_tag (view->buffer->buffer,
+                                     view->buffer->margin_tag,
+                                     &start, &end);
+        }
+    }
+}
+
 static void
 do_apply_tabs (gpointer callback_data,
                guint callback_action,
@@ -1555,6 +1667,10 @@ static GtkItemFactoryEntry menu_items[] =
   { "/Attributes/Not editable",          NULL,         do_apply_editable, FALSE, NULL },
   { "/Attributes/Invisible",             NULL,         do_apply_invisible, FALSE, NULL },
   { "/Attributes/Visible",       NULL,         do_apply_invisible, TRUE, NULL },
+  { "/Attributes/Rise",          NULL,         do_apply_rise, FALSE, NULL },
+  { "/Attributes/Large",         NULL,         do_apply_large, FALSE, NULL },
+  { "/Attributes/Indent",        NULL,         do_apply_indent, FALSE, NULL },
+  { "/Attributes/Margins",       NULL,         do_apply_margin, FALSE, NULL },
   { "/Attributes/Custom tabs",           NULL,         do_apply_tabs, FALSE, NULL },
   { "/Attributes/Default tabs",          NULL,         do_apply_tabs, TRUE, NULL },
   { "/Attributes/Color cycles",          NULL,         do_apply_colors, TRUE, NULL },
@@ -1746,7 +1862,7 @@ create_buffer (void)
       ++i;
     }
 
-#if 0  
+#if 1  
   buffer->invisible_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
                                                       "invisible", TRUE, NULL);
 #endif  
@@ -1759,6 +1875,18 @@ create_buffer (void)
   buffer->found_text_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
                                                        "foreground", "red", NULL);
 
+  buffer->rise_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
+                                                "rise", 10 * PANGO_SCALE, NULL);
+
+  buffer->large_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
+                                                "scale", PANGO_SCALE_X_LARGE, NULL);
+
+  buffer->indent_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
+                                                  "indent", 20, NULL);
+
+  buffer->margin_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
+                                                  "left_margin", 20, "right_margin", 20, NULL);
+
   tabs = pango_tab_array_new_with_positions (4,
                                              TRUE,
                                              PANGO_TAB_LEFT, 10,